﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Shakes_and_Fidget_Charplaner
{
    public partial class sfc : Form
    {
        #region Vars
        AttributeBox atr_input = new AttributeBox();
        Splash splash = new Splash();
        Player me = new Player();
        #endregion

        public sfc()
        {
            atr_input.Hide();
            splash.Show();
            InitializeComponent();
            Hide();
            Show();
            atr_input.Show();
            splash.Hide();
            splash.Close();
            AttributeInput();
        }

        #region Updates
        void UpdateTooltip()
        {
            try
            {
                //AddBasePoints(0, 0, 0, 0, 0);
                //AddEquipPoints(0, 0, 0, 0, 0);
                points.SetToolTip(str_plus, "Equip: " + me.bonus_str.ToString() + "\r\nBasis: " + me.base_str.ToString() + (me.temp_str != 0 ? "\r\nTemporär: " + me.temp_str + "" : ""));
                points.SetToolTip(dex_plus, "Equip: " + me.bonus_dex.ToString() + "\r\nBasis: " + me.base_dex.ToString() + (me.temp_dex != 0 ? "\r\nTemporär: " + me.temp_dex + "" : ""));
                points.SetToolTip(int_plus, "Equip: " + me.bonus_int.ToString() + "\r\nBasis: " + me.base_int.ToString() + (me.temp_int != 0 ? "\r\nTemporär: " + me.temp_int + "" : ""));
                points.SetToolTip(stam_plus, "Equip: " + me.bonus_stam.ToString() + "\r\nBasis: " + me.base_stam.ToString() + (me.temp_stam != 0 ? "\r\nTemporär: " + me.temp_stam + "" : ""));
                points.SetToolTip(luck_plus, "Equip: " + me.bonus_luck.ToString() + "\r\nBasis: " + me.base_luck.ToString() + (me.temp_luck != 0 ? "\r\nTemporär: " + me.temp_luck + "" : ""));
                points.SetToolTip(val_str, "Equip: " + me.bonus_str.ToString() + "\r\nBasis: " + me.base_str.ToString() + (me.temp_str != 0 ? "\r\nTemporär: " + me.temp_str + "" : ""));
                points.SetToolTip(val_dex, "Equip: " + me.bonus_dex.ToString() + "\r\nBasis: " + me.base_dex.ToString() + (me.temp_dex != 0 ? "\r\nTemporär: " + me.temp_dex + "" : ""));
                points.SetToolTip(val_int, "Equip: " + me.bonus_int.ToString() + "\r\nBasis: " + me.base_int.ToString() + (me.temp_int != 0 ? "\r\nTemporär: " + me.temp_int + "" : ""));
                points.SetToolTip(val_stam, "Equip: " + me.bonus_stam.ToString() + "\r\nBasis: " + me.base_stam.ToString() + (me.temp_stam != 0 ? "\r\nTemporär: " + me.temp_stam + "" : ""));
                points.SetToolTip(val_luck, "Equip: " + me.bonus_luck.ToString() + "\r\nBasis: " + me.base_luck.ToString() + (me.temp_luck != 0 ? "\r\nTemporär: " + me.temp_luck + "" : ""));
                /*if (plr_class.Text == "Krieger")
                    points.SetToolTip(p_armor, "Schaden durch Gegner der Stufe " + lvl.Text + ": -" + dmg_red.ToString() + "% (max -50%)");
                else if (plr_class.Text == "Magier")
                    points.SetToolTip(p_armor, "Schaden durch Gegner der Stufe " + lvl.Text + ": -" + dmg_red.ToString() + "% (max -10%)");
                else if (plr_class.Text == "Kundschaftler")
                    points.SetToolTip(p_armor, "Schaden durch Gegner der Stufe " + lvl.Text + ": -" + dmg_red.ToString() + "% (max -25%)");
                else
                    points.SetToolTip(p_armor, "Schaden durch Gegner der Stufe " + lvl.Text + ": -" + dmg_red.ToString() + "% (max -0%)");
                if (lifebonus)
                    points.SetToolTip(val_life, conv.TI(val_life.Text) / 1.25 + " + " + val_life);
                else
                    points.SetToolTip(val_life, val_life.Text);*/
                if ((lvl_op.Text == "" || lvl_op.Text == "0") && (lvl.Text != "" || lvl.Text != "0"))
                    points.SetToolTip(crit, "Gegen Gegner der Stufe " + lvl.Text + ": " + "");
            }
            catch (Exception e)
            {
                Program.LogWrite(e);
            }
        }
        private void UpdateStats()
        {
            val_str.Text = me.Str.ToString();
            val_dex.Text = me.Dex.ToString();
            val_int.Text = me.Int.ToString();
            val_stam.Text = me.Stam.ToString();
            val_luck.Text = me.Luck.ToString();
            UpdateTooltip();
        }
        #endregion

        #region Plus Clicks
        private void Plus_Click(object sender, EventArgs e)
        {
            PictureBox Plus = (PictureBox)sender;
            switch (Plus.Tag.ToString())
            {
                case "str":
                    me.base_str++;
                    break;
                case "int":
                    me.base_int++;
                    break;
                case "dex":
                    me.base_dex++;
                    break;
                case "stam":
                    me.base_stam++;
                    break;
                case "luck":
                    me.base_luck++;
                    break;
            }
            UpdateStats();
        }
        private void plus_MouseDown(object sender, MouseEventArgs e)
        {
            PictureBox Plus = (PictureBox)sender;
            Plus.Location = new Point(Plus.Location.X + 2,Plus.Location.Y + 2);
        }

        private void plus_MouseUp(object sender, MouseEventArgs e)
        {
            PictureBox Plus = (PictureBox)sender;
            Plus.Location = new Point(Plus.Location.X - 2, Plus.Location.Y - 2);
        }
        #endregion

        #region Attribute Input
        void AttributeInput()
        {
            this.Enabled = false;
            atr_input.btn_ok.Click += new EventHandler(atr_input_ok_Click);
            atr_input.btn_c.Click += new EventHandler(atr_input_c_Click);
            atr_input.load.Click += new EventHandler(atr_input_load_Click);
        }
        private void atr_input_ok_Click(object sender, EventArgs e)
        {
            me.base_str = Conv.TI(atr_input.l_str.Text);
            me.base_dex = Conv.TI(atr_input.l_dex.Text);
            me.base_int = Conv.TI(atr_input.l_int.Text);
            me.base_stam = Conv.TI(atr_input.l_stam.Text);
            me.base_luck = Conv.TI(atr_input.l_luck.Text);
            atr_input.Close();
            this.Enabled = true;
            this.BringToFront();
            UpdateStats();
        }
        private void atr_input_c_Click(object sender, EventArgs e)
        {
            atr_input.Close();
        }
        private void atr_input_load_Click(object sender, EventArgs e)
        {

        }
        #endregion

   }
}
